package cn.tedu.mall.front.controller;

import cn.tedu.mall.common.restful.JsonResult;
import cn.tedu.mall.front.service.IFrontAttributeService;
import cn.tedu.mall.pojo.product.vo.AttributeStandardVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/front/spu")
public class FrontSpuAttributeController {

    private final IFrontAttributeService frontAttributeService;

    @Autowired
    public FrontSpuAttributeController(IFrontAttributeService frontAttributeService) {
        this.frontAttributeService = frontAttributeService;
    }

    /**
     * 根据spuId查询所有属性
     */
    @GetMapping("/template/{spuId}")
    public JsonResult<List<AttributeStandardVO>> getAllAttributesBySpuId(@PathVariable("spuId") Long spuId) {
        List<AttributeStandardVO> attributeStandardVOList = frontAttributeService.getSpuAttributesBySpuId(spuId);
        return JsonResult.ok(attributeStandardVOList);
    }

}
